//
//  IDCardValidatorSpecs.swift
//  User
//
//  Created by 郑林琴 on 2017/1/11.
//  Copyright © 2017年 IB. All rights reserved.
//

import XCTest
import Nimble
import Quick
@testable import User

class IDCardValidatorSpecs: QuickSpec {
    
    override func spec() {
        
        let validator = IDCardValidator()
        
        it("验证15位 第一位为0", closure: {
            let card = "013021920101492"
            let result = validator.validate(txt: card)
            expect(result).toEventually(beFalse())
        })
        
        it("验证15位 第一位不为0", closure: {
            let card = "513021920101492"
            let result = validator.validate(txt: card)
            expect(result).toEventually(beTrue())
        })
        
        it("验证18位 第一位为0", closure: {
            let card = "013021199201014923"
            let result = validator.validate(txt: card)
            expect(result).toEventually(beFalse())
        })
        
        it("验证18位 第一位不为0", closure: {
            let card = "513021199201014923"
            let result = validator.validate(txt: card)
            expect(result).toEventually(beTrue())
        })
        
        it("长度小于15", closure: {
            let card = "51302119920101"
            let result = validator.validate(txt: card)
            expect(result).toEventually(beFalse())
        })
        
        it("长度大于15 小于18", closure: {
            let card = "5130211992010111"
            let result = validator.validate(txt: card)
            expect(result).toEventually(beFalse())
        })
        
        it("长度大于18", closure: {
            let card = "5130211992010149231"
            let result = validator.validate(txt: card)
            expect(result).toEventually(beFalse())
        })
    }
}
